package com.hjxr.quota.sdoc.service.impl;

import cn.hutool.core.util.IdUtil;
import com.hjxr.quota.sdoc.domain.TChunkInfo;
import com.hjxr.quota.sdoc.mapper.TChunkInfoMapper;
import com.hjxr.quota.sdoc.util.SnowflakeIdWorker;
import com.hjxr.quota.sdoc.service.ChunkService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;

@Service
public class ChunkServiceImpl implements ChunkService {

    @Resource
    TChunkInfoMapper tChunkInfoMapper;

    @Override
    public int saveChunk(TChunkInfo chunk) {
        chunk.setId(SnowflakeIdWorker.getUUID() + IdUtil.objectId());
        return tChunkInfoMapper.insertSelective(chunk);
    }

    @Override
    public ArrayList<Integer> checkChunk(TChunkInfo chunk) {
        return tChunkInfoMapper.selectChunkNumbers(chunk);
    }

    @Override
    public boolean checkChunk(String identifier, Integer chunkNumber) {
        return false;
    }

}
